﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

public partial class AdminLoginPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString);
        con.Open();
        string cmdStr = "Select count(*)from AdminInfo where userName='" + TextBox1.Text + "'";
        SqlCommand checkuser = new SqlCommand(cmdStr, con);
        int temp = Convert.ToInt32(checkuser.ExecuteScalar().ToString());
        if (temp == 1)
        {
            string cmdStr2 = "Select Password From AdminInfo Where Username ='" + TextBox1.Text + "'";
            SqlCommand pass = new SqlCommand(cmdStr2, con);
            string password = pass.ExecuteScalar().ToString();
            con.Close();
            if (password == TextBox2.Text)
            {
                Session["New"] = TextBox1.Text;
                Response.Redirect("admingpage.aspx");
            }
            else
            {
                Label1.Visible = true;
                Label1.Text = "Invaild Password";
            }
        }
        else
        {
            Label1.Visible = true;
            Label1.Text = "Invaild UserName";


        }



    }
}

    

  
